package com.yt.sys.server.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yt.sys.models.entity.SysAdmin;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysAdminMapper extends BaseMapper<SysAdmin> {

    /**
     * 根据用户名查找管理员
     * @param username 用户名
     * @return 管理员信息
     */
    @Select("SELECT * FROM sys_admin WHERE username = #{username} AND is_delete = 0 LIMIT 1")
    SysAdmin selectByUsername(@Param("username") String username);

    /**
     * 获取所有未删除的管理员
     * @return 管理员列表
     */
    @Select("SELECT * FROM sys_admin WHERE is_delete = 0 AND status = 1 ORDER BY create_time DESC")
    List<SysAdmin> selectAllActive();
}